<template>
	<view class="container">
		<u-navbar title='个人笔记' :title-bold='true' :border-bottom='false' ></u-navbar>
		
		<view class="card">
			<u-field
						v-model="form.title"
						placeholder="标题"
						:border-bottom='false'
						label-width='0'
						:maxlength="30"
						:field-style="{'font-size':'20px'}"
					></u-field>
			<p>{{t}}</p>
			<u-field
						v-model="form.content"
						placeholder="书写笔记"
						:border-bottom='false'
						label-width='0'
						type='textarea'
						:maxlength='2000'
					></u-field>
		</view>
		
		
		<view class="bto">
			<view class="btn" @click="save">
				保存
			</view>
		</view>
	
		<!--  -->
		
	</view>
</template>

<script>
	import {addNote, } from '@/api/index.js'
	export default{
		data(){
			return{
				form:{},
				t:''
			}
		},
		onShow() {
			let time=new Date()
			this.t=time.getFullYear()+'年'+(time.getMonth()+1)+'月'+time.getDate()+'日'
		},
		methods:{
			save(){
				let that=this
				addNote(that.form).then(res=>{
					if(res.code==1){
						uni.navigateBack()
					}else{
						uni.showToast({
							title:res.msg
						})
					}
				})
			}
		
		}
	}
</script>

<style lang="less" scoped>
	.container{
		height: 100vh;
		background-color: #EEE;
		position: relative;
		padding:20rpx 30rpx;
		.bto{
			width: 100%;
			position: absolute;
			bottom: 20rpx;
			left: 0;
		}
	
		.card{
			background-color: #FFF;
			border-radius: 10rpx;
			padding:20rpx 0;
			overflow: hidden;
			height: calc(100% - 155px);
		}
		p{
			padding: 0 36rpx;
			color: #303133;
			opacity: 0.6;
		}

	}
</style>